﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BLL;
using DAL;
using Models;
public partial class Message : System.Web.UI.Page
{

    protected string tempath1 = ConfigurationManager.AppSettings["temppath1"].ToString();//模板文件路径
    protected string htmlpath = ConfigurationManager.AppSettings["htmlpath"].ToString();//静态页文件路径
    protected void Page_Load(object sender, EventArgs e)
    {

        if (!IsPostBack)
        {
            
        }
    }

   
    protected void Button1_Click(object sender, EventArgs e)
    {
        Tb_Message Mess= new Tb_Message();
     
          Mess.Name = textfield.Value.Trim().ToString();//姓名
          Mess.Tel = textfield2.Value.Trim().ToString();//电话号码
          Mess.Email=textfield3.Value.Trim().ToString();//邮件
          Mess.Mcontent= textarea.Value.Trim().ToString();//留言内容

          Mess.Mtype = DateTime.Now.ToString();//留言时间
          makehtml makehtml = new makehtml();
          int a = Tb_MessageManager.Instance.AddTb_Message(Mess);

          int result =int.Parse(DAL.DBHelper.Query("select max(id) as maxid from Tb_Message ").Tables[0].Rows[0]["maxid"].ToString());
          string filename = makehtml.makeDetail(result.ToString(), Server.MapPath( tempath1), Server.MapPath(htmlpath), "");
      
        if (a > 0)
        {


            Response.Write("<script>alert('您的留言已经成功提交。我们会24小时内答复您！');location='Message.aspx'</script>");
        }
    }
}
